# -*- coding: utf-8 -*-
# Project  : tornado_video
# FileName : video_server.py
# Time     : 2020/9/24 11:07
# Author  : Mason101

import os
import tornado.web
import tornado.ioloop

from config import config
from handlers import handlers


class Application(tornado.web.Application):
    def __init__(self):
        setting = {
            "debug": True,
            "xsrf_cookies": True,
            "cookie_secret": "This_Is_Video_Server_Secret_",
            "static_path": os.path.join(os.path.dirname(__file__), "static"),
            "template_path": os.path.join(os.path.dirname(__file__), "templates"),
        }
        super(Application, self).__init__(handlers, **setting)


def run():
    print(f"video server is running on {config['host']}:{config['port']} ......")
    app = Application()
    app.listen(config["port"], address=config["host"])
    tornado.ioloop.IOLoop.current().start()


if __name__ == '__main__':
    run()
